package cn.tedu.boyou.website.controller;

import cn.tedu.boyou.acticle.domain.TravelCommend;
import cn.tedu.boyou.acticle.service.IStrategyCommendService;
import cn.tedu.boyou.acticle.service.ITravelCommendService;
import cn.tedu.boyou.acticle.service.ITravelService;
import cn.tedu.boyou.common.query.TravelQuery;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class IndexController {
    @Reference
    private ITravelCommendService travelCommendService;
    @Reference
    private IStrategyCommendService strategyCommendService;
    @RequestMapping("")
    public String index(Model model){
        //tcs
        List<TravelCommend> tcs = travelCommendService.getCommendsByTop5();
        model.addAttribute("tcs",tcs);
        //scs
        //因为下面这条查不出数据  汇报一次 先屏蔽了 2020 0412
        //model.addAttribute("scs",strategyCommendService.getCommendsByTop5().subList(0,1));
        return "index/index";
    }

    @Reference
    private ITravelService travelService;
    @RequestMapping("/index/travelPage")
    public String travelPag(Model model, @ModelAttribute("qo")TravelQuery qo){
        model.addAttribute("pageInfo",travelService.query(qo));
        return "index/travelPageTpl";
    }
}

